const mongoose = require("mongoose");

const leaveSchema = mongoose.Schema({
    orderNo: String,
    applyState:{
        type:Number,
        default:1
    },
    applyType: Number,
    applyUser: {
        userId: String,
        userName: String,
        userEmail: String,
    },
    leaveTime: String,
    reasons: String,
    auditUsers: String,
    curAuditUserName: String,
    auditFlows: [
        {
            userId: String,
            userName: String,
            userEmail: String,
        }
    ],
    auditLogs: [
        {
            userId: String,
            userName: String,
            createTime: Date,
            remark:String,
            action:String,
        }
    ],
    startTime: {
        type: Date,
        default: Date.now()
    },
    endTime: {
        type: Date,
        default: Date.now()
    },
    createTime: {
        type: Date,
        default: Date.now()
    },
})

module.exports = mongoose.model("leave", leaveSchema, "leaves");